<template>
    <div>
        <el-upload
                class="upload-demo"
                drag
                ref="upload"
                action=""
                :file-list="fileList"
                :auto-upload="true"
                :http-request="uploadFile"
                name="file"
                multiple>
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="el-upload__tip" slot="tip">单个文件上传</div>
        </el-upload>
    </div>
</template>

<script>
    import {upload} from '@/api/index'
    export default {
        name: "PageThree",
        data(){
            return{
                fileList:[]
            }
        },
        methods:{
            uploadFile(file){
                console.log("file",file)
                let data = new FormData();
                data.append("file",file.file)
                data.append("userId",12345);
                upload(data).then(res=>{
                    if (res.code == 0) {
                        console.log(res)
                        this.$notify({
                            title: '成功',
                            message: res.msg,
                            type: 'success'
                        });
                    }

                })
            }

        }
    }
</script>

<style scoped>

</style>
